package me.khrystal.util;

import android.content.Context;

import com.google.gson.Gson;

import me.khrystal.MainApplication;

/**
 * Created by Yao on 2015/12/14.
 */
public class Global {
    private static final ThreadLocal<Gson> reuseGson = new ThreadLocal<Gson>() {
        @Override
        protected Gson initialValue() {
            return new Gson();
        }
    };

    /**
     * 从已经存在的线程获取Gson对象
     * @return
     */
    public static Gson getGson() {
        return reuseGson.get();
    }

    /**
     * 获取全局上下文
     * @return
     */
    public static Context getContext() {
        return MainApplication.getInstance();
    }

}
